package dao;

import redis.clients.jedis.Jedis;

import java.nio.charset.StandardCharsets;

/**
 * 封装redis，将对象序列化后存在redis中
 */
public class redis {

    public static Object get(String key) {
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        byte[] o = jedis.get(key.getBytes());
        Object result = SerializeUtil.unserialize(o);
        return result;
    }

    public static void set(String key, Object value) {
        Jedis jedis = new Jedis("127.0.0.1", 6379);
//        String tmp = SerializeUtil.serialize(value);
        String o = jedis.set(key.getBytes(), SerializeUtil.serialize(value));
        System.out.println(o);

    }


}
